package com.swh.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.view.InternalResourceViewResolver;

/**
 * @Author: swh
 * @Description:
 * @Date: 2020/12/14 16:29
 * @Version: 1.0
 */
@Configuration
@EnableWebMvc
public class MvcConfig implements WebMvcConfigurer {

    /**
     * @return 静态资源放行
     **/
    @Override
    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
        configurer.enable();
    }

    /**
     * @return 拦截器
     **/
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        LoginInterceptor loginInterceptor = new LoginInterceptor();
//        registry.addInterceptor(loginInterceptor)
//                //拦截
//                .addPathPatterns(new String[]{"/guguanjia/**", "**/*.html"})
//                //放行
//                .excludePathPatterns(new String[]{"/notauth.html", "/index.html", "/notlogin.html"});
    }

    @Bean
    public InternalResourceViewResolver getInternalResourceViewResolver() {
        InternalResourceViewResolver viewResolver = new InternalResourceViewResolver("/html/", ".html");
        return viewResolver;
    }


}
